/**
 * 权限控制
 */

import NProgress from 'nprogress'
import router from '@/router'
import 'nprogress/nprogress.css'
import { PageEnum } from './enums/pageEnum'
import config from './config'
import { createApp } from 'vue'
import App from './App.vue'
import install from './install'
import './styles/index.scss'
import 'virtual:svg-icons-register'
// NProgress配置
NProgress.configure({ showSpinner: false })


const loginPath = PageEnum.LOGIN

router.beforeEach(async (to, from, next) => {
    // 开始 Progress Bar
    NProgress.start()
    document.title = to.meta.title ?? config.title
    if (to.path === loginPath) {
        next({ path: "/" })
    } else {
        next()
    }

})

router.afterEach(() => {
    NProgress.done()
})
const app = createApp(App)
app.use(install)
app.mount('#app')